package com.orange.base.core.bean;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

public class TableMetaData {

    /**
     * 表名称
     */
    private String tableName;

    /**
     * 表注释
     */
    private String tableRemarks;

    /**
     * 主键
     */
    private String primaryKey;

    /**
     * 索引
     */
    private List<TableIndexInfo> index = new ArrayList<TableIndexInfo>();

    /**
     * 
     * /** 列信息
     */
    private Map<String, ColumnMetaData> columnMap = null;

    public TableMetaData(String tableName, String tableRemarks, String primaryKey, List<TableIndexInfo> index,
            Map<String, ColumnMetaData> columnMap) {
        this.tableName = tableName;
        this.tableRemarks = tableRemarks;
        this.primaryKey = primaryKey;
        this.index = index;
        if (index != null && !index.isEmpty()) {
            List<TableIndexInfo> unmodifiableList = Collections.unmodifiableList(index);
            this.index = unmodifiableList;
        }
        if (columnMap != null && !columnMap.isEmpty()) {
            Map<String, ColumnMetaData> unmodifiableMap = Collections.unmodifiableMap(columnMap);
            this.columnMap = unmodifiableMap;
        }
    }

    public String getTableName() {
        return tableName;
    }

    public String getTableRemarks() {
        return tableRemarks;
    }

    public String getPrimaryKey() {
        return primaryKey;
    }

    public List<TableIndexInfo> getIndex() {
        return index;
    }

    public Map<String, ColumnMetaData> getColumnMap() {
        return columnMap;
    }

    public boolean isColumn(String columnName) {
        return columnMap.containsKey(columnName);
    }
}
